package net.apexes.demo.codegen.ormlite.column;

import net.apexes.commons.ormlite.Column;
import net.apexes.commons.ormlite.ForeignKey;
import net.apexes.commons.ormlite.Index;
import net.apexes.demo.codegen.ormlite.column.base.QEntityBase;
import net.apexes.demo.codegen.ormlite.entity.ShopTemplate;

/**
 * QShopTemplate is a ORMLite query type for ShopTemplate
 * @see ShopTemplate
 */
public class QShopTemplate extends QEntityBase<ShopTemplate> {

    public static final QShopTemplate $ = new QShopTemplate("SHOP_TEMPLATE");

    public final Column shopId = field("shopId").columnName("SHOP_ID").varchar(22).notNull().build();

    public final Column templateId = field("templateId").columnName("TEMPLATE_ID").varchar(22).notNull().build();

    public class Indexs {

        public final Index constraintIndexAd = index("CONSTRAINT_INDEX_AD").column(shopId).build();

        public final Index constraintIndexAd3 = index("CONSTRAINT_INDEX_AD3").column(templateId).build();

        public final Index primaryKeyAd = index("PRIMARY_KEY_AD").unique().column(id).build();

    }

    public final Indexs ix = new Indexs();

    public class ForeignKeys {

        public final ForeignKey constraintAd3 = foreignKey(shopId, "SHOP", "ID");

        public final ForeignKey constraintAd3e = foreignKey(templateId, "TEMPLATE", "ID");

    }

    public final ForeignKeys fk = new ForeignKeys();

    public QShopTemplate(String tableName) {
        super(ShopTemplate.class, tableName);
    }

    @Override
    public ShopTemplate newInstance() {
        return new ShopTemplate();
    }

    @Override
    public Object getFieldValue(ShopTemplate instance, String fieldName) {
        switch (fieldName) {
            case "shopId":
                return instance.getShopId();
            case "templateId":
                return instance.getTemplateId();
            default:
                return super.getFieldValue(instance, fieldName);
        }
    }

    @Override
    public void setupFieldValue(ShopTemplate instance, String fieldName, Object value) {
        switch (fieldName) {
            case "shopId":
                instance.setShopId((java.lang.String) value);
                break;
            case "templateId":
                instance.setTemplateId((java.lang.String) value);
                break;
            default:
                super.setupFieldValue(instance, fieldName, value);
                break;
        }
    }

}

